package com.thinking.exersises;

/**
 * Created by IntelliJ IDEA.
 * User: pvg
 * Date: 11/1/11
 * Time: 6:30 PM
  Write a program that uses two nested for loops and the modulus operator (%)
 to detect and print prime numbers
 (integral numbers that are not evenly divisible by any other numbers except for themselves and 1).
 */
public class Exersise4page96 {
    public static void primaries(int upperBorder) {
        for (int i = 2; i <= upperBorder; i ++) {
            System.out.println("number is: " + i);
            for(int j = 2; j <= Math.sqrt(i); j++) {
                if ((i % j == 0) && i !=j ) {
                    System.out.println("not prime");
                    break;
                }
            }


        }

    }

    public static void main(String[] args) {
        primaries(6);
    }
}
